/* Copyright (C) 2009, Lukasz Kaczmarczyk (likask AT civil.gla.ac.uk)
 * --------------------------------------------------------------
 * FIXME: DESCRIPTION
 */

/* This file is part of yaffems.
 * yaffems is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.
 *
 * yaffems is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with yaffems. If not, see <http://www.gnu.org/licenses/>. */

#include <make_mesh.hpp>
#include <cgal_interface.hpp>
#include <snes_functions.hpp>
#include <fem.h>

void driver_partition_mesh(Interface& moab,int argc, char *argv[]);
void driver_GetFromOption(snes_ctx *ctx);
void driver_partition(Interface& moab);
void driver_create_meshset(Interface& moab,EntityHandle meshset,snes_ctx *ctx);
PetscErrorCode driver_setup_snes(snes_ctx ctx,SNES *snes);
PetscErrorCode driver_destroy_matrices(Mat M,Mat B,Vec F,Vec D,Vec Lambda,Vec FfromArray,Vec DfromArray,snes_ctx *ctx);
PetscErrorCode driver_create_matrices(Interface& moab,EntityHandle meshset,Mat *M,Mat *B,Vec *F,Vec *D,Vec *Lambda,Vec *FfromArray,Vec *DfromArray,snes_ctx *ctx);
PetscErrorCode driver_destroy_matrices_hierarchical(Mat M,Mat B,Vec F,Vec D,Vec F_hierarchical,Vec D_hierarchical,Vec Lambda,Vec FfromArray,Vec DfromArray,snes_ctx *ctx);
PetscErrorCode driver_setup_snes(Mat M,Mat B,Vec Dofs,Vec F,snes_ctx *ctx,SNES *snes);
PetscErrorCode driver_setup_arc_length(Vec Dofs,snes_ctx *ctx);
PetscErrorCode driver_solve_snes(SNES snes,snes_ctx *ctx,Vec D);
PetscErrorCode driver_snes_destroy(SNES snes,snes_ctx *ctx);
void driver_data_on_mesh(Interface& moab,EntityHandle meshset,snes_ctx *ctx,Vec D,Vec D_hierarchical,Vec F);
void driver_calulate_forces(SNES snes,Interface& moab,EntityHandle meshset,snes_ctx *ctx,Vec DfromArray,Vec FfromArray);
void driver_calulate_griffith_forces(SNES snes,Interface& moab,EntityHandle meshset,snes_ctx *ctx,Vec DfromArray,Vec FfromArray);
void driver_data_on_mesh_arc_length(Interface& moab,EntityHandle meshset,snes_ctx *ctx,Vec DfromArray);
void driver_set_data_from_mesh_arc_length(Interface& moab,EntityHandle meshset,snes_ctx *ctx,Vec DfromArray);
double driver_solution_with_alpha_r_adaptation(SNES snes,snes_ctx *ctx,Mat M,Vec FfromArray,Vec DfromArray);
PetscErrorCode driver_create_matrices_hierarchical(Interface& moab,EntityHandle meshset,Mat *M,Mat *B,Vec *F,Vec *D,Vec *F_hierarchical,Vec *D_hierarchical,Vec *Lambda,Vec *FfromArray,Vec *DfromArray,snes_ctx *ctx);
bc_type bc_free_all(int boundcond,double *coord,double *val,bc_type bc);
bc_type bc_block_material(int boundcond,double *coord,double *val,bc_type bc);
bc_type bc_block_space(int boundcond,double *coord,double *val,bc_type bc);
bc_type bc_block_material_not_at_fornt(int boundcond,double *coord,double *val,bc_type bc);
